import axios from "axios";
import { ElMessage } from "element-plus";
let instance = axios.create({
  baseURL: "https://reactapi.iynn.cn/",
  //请求时间,如果超过这个时间就会报错
  //设置超时时间
  timeout: 5000,
});
  //请求拦截器
  instance.interceptors.request.use((config) => {
    // console.log("每一次发送请求都会执行");
    //携带请求头
    if(localStorage.getItem("Authorization")){
        config.headers.Authorization = localStorage.getItem("Authorization");
    }
    return config;
  });
instance.interceptors.response.use((res) => {
  // if (res.data?.data?.token) {
  //   localStorage.setItem("token", res.data.data.token);
  // }
//   ElMessage({
//     message: res.data.message,
//     type: res.data.code==="200"?"success":"error"
//   });
  return res;
});
export default instance;